
class Student{
    public int count=0;
    public synchronized void add(){
        count++;
    }
}

public class test {


    public static void main(String[] args) throws InterruptedException {

        Student student = new Student();
        Thread thread = new Thread(()->{
         for(int i =0;i<10000;i++){
             student.add();
         }

        });

        Thread thread1 = new Thread(()->{
          for (int i = 0;i<10000;i++){
              student.add();
          }
        });
        thread.start();
        thread1.start();
        thread.join();
        thread1.join();
        System.out.println(student.count);
    }
}
